package test.ych.com.test

import java.util.concurrent.locks.ReentrantLock

class Calculator {
//    open abstract fun test()
    object Single{
        val name = "single"
    }

    fun sum(a:Double? = 10.0,b:Double = 11.0): Double? {
        //!! 做了非空处理
        //？.  可空
        //?:  空判断

        //创建线程
//        object : Thread() {
//            override fun run() {
//                println("running from Thread: ${Thread.currentThread()}")
//            }
//        }.start()
//        Thread({
//        }).start()


        return a!!.plus(b)
    }

    @Synchronized fun testSycnFunction(){
        println("test Synchronized,koltin没有sycnchronized 与 volatile")
    }

    fun testSycnBlock(){
        synchronized(this){

        }
        synchronized(Calculator::class.java){

        }
    }

}